<template>
  <div>
    <el-form :model="{}" size="medium" :inline="true" label-width="60px">
      <el-form-item label="操作栏" prop="">
        <el-button :disabled="selection.length === 0" type="primary" plain icon="el-icon-plus" size="medium"
          @click="Commit">添加</el-button>
      </el-form-item>
    </el-form>
    <el-table ref="multipleTable" v-loading="loading" :data="noticeList" @selection-change="handleSelectionChange"
      @row-click="clickRow">
      <el-table-column type="selection" width="55">
      </el-table-column>
      <el-table-column label="序号" align="center" prop="order" width="50" />
      <el-table-column label="设备编号" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.equipmentNum || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="设备名称" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.equipmentName || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="品牌" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.brand || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="规格型号" align="center" min-width="130" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.model || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="供应商" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.supplierName || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="单位" align="center" min-width="150">
        <template slot-scope="scope">
          <span>{{ scope.row.unitName || '-' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" min-width="180" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.remark || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="创建部门" align="center" min-width="180" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.deptName || '-' }}
        </template>
      </el-table-column>
    </el-table>
    <div class="card-div">
      <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
        @pagination="getList" />
    </div>
  </div>
</template>

<script>
import { getEquipmentList } from "@/api/maintenance/insurance/insurance.js";

export default {
  components: {
  },
  props: ['List'],
  data () {
    return {
      // 遮罩层
      loading: true,
      opendetailed: false,
      detailedObj: {},
      ImageOpen: false,
      ImageSrc: '',
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      dictdatalist: [],
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 弹出层表格数据
      noticeList: [],
      rowObj: {},
      // 弹出层标题
      title: "修改设备基值",
      // 是否显示弹出层
      open: false,
      selection: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderByColumn: 'equipmentAccountId',
        isAsc: 'desc'//倒叙
      },
    };
  },
  created () {
    this.getList();
  },
  methods: {
    clickRow (row) {//单击行选中前面复选框
      this.$refs.multipleTable.toggleRowSelection(row);
    },
    /** 查询列表 */
    async getList (value) {
      this.loading = true;
      let values = value || {}
      let params = {
        ...this.queryParams,
        ...values,
        'equipmentBaseVo.equipmentName': values.equipmentName,
        'params[userStatuses]': '0,1,2,4',
        'params[scope1]': 1,
        'params[scope4]': 1,
        'params[upkeepPlanFlag]': true,
        'params[upkeepLevelIdIsNull]': 0,
        // 'params[flag]': 'n'
      }
      let response = await getEquipmentList(params)
      this.noticeList = response.data && response.data.map((item, index) => {
        return {
          ...item,
          order: index + 1
        }
      });
      // this.$refs.multipleTable.clearSelection();
      this.total = response.total;
      this.loading = false;
    },
    // 多选框选中数据
    handleSelectionChange (selection) {
      this.selection = selection
    },
    Commit () {
      this.$emit('clearOpen', this.selection)
    },
    toggleSelection (rows) {
      if (rows) {
        rows.forEach(row => {
          this.$refs.multipleTable.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },

  },
  filters: {
  }
};
</script>
<style lang="scss" scoped>
.red {
  color: red;
}
</style>